package cn.wangsy.zhidao.p20170314;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

public class JdbcTest {

	public static void main(String[]args) {
		
		/*try{
			Class.forName("com.mysql.jdbc.Driver");
			Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.1.12:3306/txl","root","123456");
			System.out.println(connection.isClosed());
		}catch(Exception e){
			e.printStackTrace();
		}*/

		
		try{
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			Connection connection = DriverManager.getConnection("jdbc:sqlserver://192.168.1.50:1433;DatabaseName=RowSeatSys;integratedSecurity=false","sa","123");
			System.out.println(connection.isClosed());
			
			Statement statement = connection.createStatement();
			ResultSet rs = statement.executeQuery("select * from Meeting");
			while(rs.next()){
				ResultSetMetaData metaData = rs.getMetaData();
				for(int i = 1;i <= metaData.getColumnCount();i++){
					System.out.print(rs.getObject(i) + "|");
				}
				System.out.println();
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
	
}
